<?php
if (ereg("menuCategories\.php$", $_SERVER["SCRIPT_FILENAME"])) require("../head.php") ;
?>

<table class="listCategories"><tr>
        <td class="liste">
<?php
$requete = "SELECT * FROM Categorie ;" ;
connect() ;
$result = executerRequete($requete, $GLOBALS['debug']) ;
while ($row = mysql_fetch_assoc($result))
{
?>
    <div class="categorie categorie_<?= $row['id'] ?>">
        <div class="titre">
            <a href="index.php?page=listVideos&categorie=<?= $row['id'] ?>"><?= $row['nom'] ?></a>
            <?php if (niveauOK(2)) { ?>
            <span class="actions">
                <a class="edition" href="index.php?page=updateCategorie&id=<?= $row['id'] ?>">modifier</a>
                - <a class="edition" href="index.php?page=updateCategorie&supprimer=<?= $row['id'] ?>">supprimer</a>
            </span>
            <?php } ?>
        </div>
    </div>
<?php }
mysql_close() ;
?>
<?php if (niveauOK(2)) { ?><div class="nouvelleCategorie"><a class="edition" href="index.php?page=updateCategorie">Nouvelle catégorie</a></div><?php } ?>
        </td>
    </tr>
    <tr><td class="description"></td>
</tr></table>
<script language="JavaScript" type="text/JavaScript">
$("div.listCategories div.categorie").mouseover(function(e){
    id = $(this).find("a").attr("href").substring(31) ;
    $.getJSON("utilities/jsonDescriptions/jsonDescriptionCategorie.php?id="+id, {}, function(data){
        $("div.listCategories table.listCategories").append('<div class="description aide">'+data.description+'</div>') ;
        $("div.listCategories div.description").css("left", e.pageX+10).css("top", e.pageY+10) ;
    }) ;

});
$("div.listCategories").mouseout(function(){
    $("div.listCategories div.description").remove() ;
});
</script>